# -*- coding: utf-8 -*-
"""
Created on 2024-03-17 21:40:52
---------
@summary:
---------
@author: poppies
"""

import feapder


class Douban(feapder.AirSpider):
    def start_requests(self):
        for page in range(2):
            yield feapder.Request(f"https://movie.douban.com/top250?start={page * 25}&filter=",
                                  download_midware=[self.download_midware, self.custom_download_middleware])

    # 默认中间件
    def download_midware(self, request):
        request.headers = {
            'User-Agent': '123'
        }
        return request

    # 自定义中间件, 需要在request对象中指定中间件名称
    def custom_download_middleware(self, request):
        request.proxies = {
            'http': 'http://127.0.0.1:7890'
        }
        return request

    def parse(self, request, response):
        pass


if __name__ == "__main__":
    Douban().start()
